package org.japo.java.entities;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
 *
 * @author José A. Pacheco Ondoño - joanpaon@gmail.com
 */
@XmlRootElement(name = "rotulo")
@XmlType(propOrder = {"familia", "negrita", "cursiva", "talla"})
public class Rotulo {

    // Identificación de propiedades
    public static final String PROP_FAMILIA = "familia";
    public static final String PROP_NEGRITA = "negrita";
    public static final String PROP_CURSIVA = "cursiva";
    public static final String PROP_TALLA = "talla";
    //
    // Campos de la entidad
    private String familia;
    private boolean negrita;
    private boolean cursiva;
    private int talla;
    // 
    // Soporte al cambio de propiedad
    private transient final PropertyChangeSupport propertyChangeSupport = 
            new java.beans.PropertyChangeSupport(this);

    public Rotulo() {
        familia = "Serif";
        negrita = false;
        cursiva = false;
        talla = 18;
    }

    public Rotulo(String familia, boolean negrita, boolean cursiva, int talla) {
        this.familia = familia;
        this.negrita = negrita;
        this.cursiva = cursiva;
        this.talla = talla;
    }

    public String getFamilia() {
        return familia;
    }

    public void setFamilia(String familia) {
        String oldFamilia = this.familia;
        this.familia = familia;
        propertyChangeSupport.firePropertyChange(PROP_FAMILIA, oldFamilia, familia);
    }

    public boolean isNegrita() {
        return negrita;
    }

    public void setNegrita(boolean negrita) {
        boolean oldNegrita = this.negrita;
        this.negrita = negrita;
        propertyChangeSupport.firePropertyChange(PROP_NEGRITA, oldNegrita, negrita);
    }

    public boolean isCursiva() {
        return cursiva;
    }

    public void setCursiva(boolean cursiva) {
        boolean oldCursiva = this.cursiva;
        this.cursiva = cursiva;
        propertyChangeSupport.firePropertyChange(PROP_CURSIVA, oldCursiva, cursiva);
    }

    public int getTalla() {
        return talla;
    }

    public void setTalla(int talla) {
        int oldTalla = this.talla;
        this.talla = talla;
        propertyChangeSupport.firePropertyChange(PROP_TALLA, oldTalla, talla);
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.removePropertyChangeListener(listener);
    }
}
